var app = getApp();
var util = require("../../utils/libs.js")
var api = require("../../utils/api.js")
Page({
  data: {
     contentList:[],
     uid:"",
     id:7,
     page:1,
     limit:10,
     skillid:null
  },
  onLoad (options) {
    let that = this
    // 页面初始化 options为页面跳转所带来的参数
    var uid = wx.getStorageSync('uid')
    that.setData({
      uid:uid,
      id:options.id
    })
    that.getlist()
  },
  getlist(){
    let that = this
    that.setData({
      skillid:1
    })
    util.request(api.buildArticleList,{
      id:that.data.id,
      uid:that.data.uid,
      page:that.data.page,
      limit:that.data.limit
     },"GET")
     .then(function (res) {
       if(res.error_code === 0){
          that.setData({
            contentList:res.data.list
          })
       }
     })
  },
  gettopicList(){
    let that = this
    that.setData({
      skillid:2
    })
    util.request(api.topicList,{
      uid:that.data.uid,
      page:that.data.page,
      limit:that.data.limit
     },"GET")
     .then(function (res) {
       if(res.error_code === 0){
          that.setData({
            contentList:res.data.list
          })
       }
     })
  },
  getcommentList(){
    let that = this
    that.setData({
      skillid:3
    })
    util.request(api.commentList,{
      uid:that.data.uid,
      id:that.data.id,
      page:that.data.page,
      limit:that.data.limit
     },"GET")
     .then(function (res) {
       if(res.error_code === 0){
          that.setData({
            contentList:res.data.list
          })
       }
     })
  },
  goDetail(e){
    let that = this 
    let idType = that.data.skillid
    let id = e.currentTarget.dataset.id
    if(idType == 1){
     wx.navigateTo({
       url:"/pages/listdetais/listdetais?id="+id
     })
    }else if(idType == 2){
     wx.navigateTo({
       url:"/pages/writing/writing?id="+id
     })
    }else if(idType == 3){
     wx.navigateTo({
       url:"/pages/assist/assist?id="+id
     })
    }
   },
  onReady () {
    // 页面渲染完成
  },
  onShow () {
    // 页面显示
  },
  onHide () {
    // 页面隐藏

  },
  onUnload () {
    // 页面关闭

  }
})
